import axios from 'axios';

let instance = axios.create({
  baseURL: '/api',
  timeout: 5000,
});
// 请求拦截器
instance.interceptors.request.use((config) => {
  //设置用户的token
  if (localStorage.getItem('token'))
    config.headers.token = localStorage.getItem('token');
  return config
});
// 响应拦截器
instance.interceptors.response.use((res) => {
  return res.data;
}, (error) => {
  return Promise.reject(error)
})
export default instance;
